// Copyright (c) 2022, hzmes and contributors
// For license information, please see license.txt
/* eslint-disable */

frappe.query_reports["SRM Sample Admit DocReport"] = {
	"filters": [
		{
			"fieldname": "creation_from",
			"fieldtype": "Date",
			"label": "制单日期从",
			"default": frappe.datetime.add_days(frappe.datetime.get_today(), -360),
			"width": 0
		},
		{
			"fieldname": "creation_to",
			"fieldtype": "Date",
			"label": "制单日期到",
			"default": frappe.datetime.add_days(frappe.datetime.get_today(), 7),
			"width": 0
		},
		{
			"fieldname": "is_assign",
			"fieldtype": "Check",
			"label": "已下发",
			"default": 1,
			"width": 0
		},
	],

	onload: function(report) {
		setInterval(function() {
			$(".dt-row").click(function(){
				console.log($(this).context);
				$(this).css('background-color', 'yellow');
				frappe.query_report.datatable.style.setStyle(`.dt-row-2`, {backgroundColor: '#00ff00'});
				// $(this).css('backgroud-color',"BLACK")
			})
		},100)

	},

	"formatter": function(value, row, column, data, default_formatter) {

		value = default_formatter(value, row, column, data);
		let format_fields = ["quality_confirm_user"];

		if (format_fields && data && data["quality_confirm_user"]) {
			var color_field = data["quality_confirm_user"];
			let color = undefined;

			if (color_field) {
				color = 'green';
			}
			if (color){
				value =`<div style='margin:0px;padding-left:5px;color:${color}!important;'>${value}</div>`            
			}	
		}

		return value;
	},

	after_datatable_render: function(datatable_obj) {
		// 设置高度35(默认写死了40)
		frappe.query_report.datatable.style.setStyle(`.dt-scrollable`, {height: '35vw'});
	},

	get_datatable_options(options) {
        return Object.assign(options, {
            checkboxColumn: true,
			// events: {
			// 	onCheckRow: function(data) {
			// 		// var select_row = []
			// 		data[18].content = 'Y'
			// 		console.log(data[2].content)
			// 	},

			// 	onSwitchColumn: function(data) {
			// 		console.log('SwitchColumn')
			// 	},
			// }
        });
    },

};

